package com.jhws.business.property.controller;

import com.jhws.common.base.bo.JsonRespData;
import com.jhws.business.property.bo.PropertyFeeFormula;
import com.jhws.business.property.service.PropertyFeeFormulaService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Map;

@Controller
@RequestMapping("/property/feeFormula")
public class PropertyFeeFormulaController {
    @Resource
    private PropertyFeeFormulaService propertyFeeFormulaService;

    /**
     * 保存物业缴费公式
     *
     * @param propertyFeeFormula 公式信息
     */
    @RequestMapping("savePropertyFeeFormula.x")
    @ResponseBody
    public JsonRespData savePropertyFeeFormula(PropertyFeeFormula propertyFeeFormula) throws Exception {
        propertyFeeFormulaService.savePropertyFeeFormula(propertyFeeFormula);
        return new JsonRespData("", 1, "添加公式成功");
    }

    /**
     * 分页查询公式信息
     *
     * @param param Map
     * @return 公式信息列表
     */
    @RequestMapping("queryPropertyFeeFormulaPage.x")
    @ResponseBody
    public JsonRespData queryPropertyFeeFormulaPage(@RequestParam Map param) {
        Map data = propertyFeeFormulaService.queryPropertyFeeFormulaPage(param);
        return new JsonRespData("", 1, data);
    }

    /**
     * 保存更新使用公式
     * @param id
     * @param commCode
     * @param isEnable
     */
    @RequestMapping("enableFormula.x")
    @ResponseBody
    public JsonRespData enableFormula(String id, String commCode, boolean isEnable) {
        propertyFeeFormulaService.saveEnableFormula(id, commCode, isEnable);
        return new JsonRespData("", 1, "");
    }

    /**
     * 删除公式信息
     *
     * @param id 公式信息ID
     */
    @RequestMapping("deletePropertyFeeFormula.x")
    @ResponseBody
    public JsonRespData deletePropertyFeeFormula(String id) throws Exception {
        propertyFeeFormulaService.deletePropertyFeeFormula(id);
        return new JsonRespData("", 1, "删除成功");
    }
}
